/**
**************************************************************************************
*Palisma - Secrets of the Illuminati is an open-source 2D RPG                        *
*Copyright (C) 2006, Tony Sparks                                                     *
*                                                                                    *
*This library is free software; you can redistribute it and/or                       *
*modify it under the terms of the GNU Lesser General Public                          *
*License as published by the Free Software Foundation; either                        *
*version 2.1 of the License, or (at your option) any later version.                  *
*                                                                                    *
*This library is distributed in the hope that it will be useful,                     *
*but WITHOUT ANY WARRANTY; without even the implied warranty of                      *
*MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU                   *
*Lesser General Public License for more details.                                     *
*                                                                                    *
*You should have received a copy of the GNU Lesser General Public                    *
*License along with this library; if not, write to the Free Software                 *
*Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA      *
**************************************************************************************
*/
#include "StdAfx.h"
#include "HUD.h"

#include "EntityManager.h"
#include "IWeapon.h"
#include "../Kernel.h"

extern Kernel* g_kernel;


HUD::HUD(Player* p)
{
    m_player = p;
    m_debugMode = true;
    m_showInventory = false;
    m_show  = true;
}

HUD::HUD(void)
{
    m_player = NULL;
    m_debugMode = true;
    m_showInventory = false;
    m_show = true;
}

HUD::~HUD(void)
{
}


/** Draw the Players inventory */
void HUD::DrawInventory(IRender* r, ICamera* cam)
{
    // TEMP
    r->DrawString( 0, 400, m_player->m_weaponInventory.CurrentItem()->GetName().c_str() );

}

/** Draw the HUD */
void HUD::DrawHUD(IRender* r, ICamera* cam)
{
    if ( m_debugMode )
    {
        DrawFPS( r, cam );
        DrawResCount( r, cam );
    }

    if ( m_show && m_player )
    {
        DrawInventory( r, cam );
    }
}


/** Draw Health */
void HUD::DrawHealth(IRender* r, ICamera* cam)
{

}

/** Draw Gold coins amount */
void HUD::DrawCoins(IRender* r, ICamera* cam)
{

}



/*--------------------------
    Debug info
---------------------------*/

/** Draw FPS counter */
void HUD::DrawFPS(IRender* r, ICamera* cam)
{
    r->SetColor(1, 1, 1 );
    float fps = 1.0f / ( g_kernel->GetFrameTime()/1000.0f );
    r->DrawString(0,0, "FPS: %6.2f", fps );
}

/** Draw Active Entities count*/
void HUD::DrawResCount(IRender* r, ICamera* cam)
{
    r->SetColor(1, 1, 1 );
    r->DrawString( 120, 0, "Entities: %4i", EntityManager::GetInstance()->Count() );
    r->DrawString( 240, 0, "Textures: %4i", g_kernel->GetResource()->Textures() );
    r->DrawString( 360, 0, "Sounds: %4i", g_kernel->GetResource()->Sounds() );
    int height = g_kernel->GetCvars()->GetFloatValue("v_height");
    r->DrawString( 5, height-20, ("CurrentGameState: " + g_kernel->GetGame()->GetCurrentState()->GetName()).c_str() );
}